
/**
 * Define Start
 */
// 父类
function Person () {
  this.hobbies = ['music', 'reading'];
}
// 父类原型链函数
Person.prototype.say = function () {
  console.log('I am a person');
}
// 子类
function Student () {
  // 构造函数继承（主要添加子类的属性）
  Person.call(this);
}
// 原型链继承（主要继承父类的方法）
Student.prototype = new Person();
// 修复constructor
Student.prototype.constructor = Student;
/**
 * Define End
 */

//
var student1 = new Student();
var student2 = new Student();
// student1 -> ​​​​​Student { hobbies: [ 'music', 'reading' ] }​​​​​
// student1.__proto__ -> ​​​​​Student { hobbies: [ 'music', 'reading' ], constructor: [λ: Student] }​​​​​
console.log(student1, student2);
// ​​​​​Student { hobbies: [ 'music', 'reading' ] }, Student { hobbies: [ 'music', 'reading' ] }​​​​​

student1.hobbies.push('writing');
// student1 -> ​​​​​Student { hobbies: [ 'music', 'reading', 'writing' ] }
// student1.__proto__ -> ​​​​​Student { hobbies: [ 'music', 'reading' ], constructor: [λ: Student] }​​​​​
console.log(student1, student2);
// ​​​​​Student { hobbies: [ 'music', 'reading', 'writing' ] } ,Student { hobbies: [ 'music', 'reading' ] }​​​​​


